#!/bin/sh

function HasCmd()
{
    LANG=en_US.UTF-8 type $1
    return $?
}

arch=$(uname -m)

gopkgname=
gopkgversion=1.9.2
gopkgurl=https://www.golangtc.com/static/go/${gopkgversion}
if [ x${arch::3} == xarm ]; then
    gopkgname=go1.9.2.linux-armv6l.tar.gz
elif [ x${arch} == xx86_64 ]; then
    gopkgname=go1.9.2.linux-amd64.tar.gz
else
    echo "Arch ${arch} not supported"
    exit 1
fi

HasCmd wget
if [ $? -eq 0 ]; then
    wget ${gopkgurl}/${gopkgname}
else
    curl -o ${gopkgname} ${gopkgurl}/${gopkgname}
fi

go get -u github.com/gpmgo/gopm

go get -u github.com/nsf/gocode
go get -u github.com/rogpeppe/godef
go get -u github.com/golang/lint/golint
go get -u github.com/lukehoban/go-find-references
go get -u github.com/lukehoban/go-outline
go get -u sourcegraph.com/sqs/goreturns
go get -u golang.org/x/tools/cmd/gorename
go get -u github.com/tpng/gopkgs
go get -u github.com/newhook/go-symbols
go get -u github.com/derekparker/delve/cmd/dlv
